<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>欢迎注册</title>
<meta name="viewport" content="width=device-width" />
<jsp:include page="include.jsp"></jsp:include>
<script type="text/javascript">
function toVaild(){
	if($('#userCode').val() == null || $('#userCode').val() == ''){
		$('#msg').html("请录入用户名");
		return false;
	}
	if($('#userPass').val() == null || $('#userPass').val() == ''){
		$('#msg').html("请录入密码");
		return false;
	}
	//邮箱非必需：
	/* if(!$('#email').val()){
		$('#msg').html("请录入邮箱");
		return false;
	} */
	return true;
}
jQuery(function($){
	$("#confirmAttach").click( function () {
		if(!toVaild()){return;}
		$.ajax({
			  type: 'POST',
			  url: 'attachOk',
			  async: false,//是否异步
			  contentType: "application/json; charset=utf-8",
		      data: JSON.stringify($('#AttachFM').serializeJSON()),
			  success: function(d){
				  if(d.error != null && d.error==1){
					  $('#msg').html(d.msg);
				  }else{
					  $('#msg').html(d.msg);
					  window.location.href = "exit";  
				  }
			  }
		});
	});
	$('#backLogin').click(function(){
		window.location.href = "exit";
	});
});
</script>
</head>
<body style="overflow: hidden;">
	<div data-role="page" id="pageone" style="width: 100%">
		<div data-role="header">
			<h1>欢迎注册(微服务版)</h1>
		</div>
		<div data-role="content">
			<p style="color: red;width: 100%;text-align: center;">&nbsp;<span id="msg">${msg}</span></p>
			<form id="AttachFM" method="post">
				<div data-role="fieldcontain" style="margin: 10px">
					<label for="userCode" data-icon="user">用户名：</label> 
					<input type="text" name="userCode" id="userCode" value="${userCode}"> 
					<label for="userPass" data-icon="lock">密码：</label> 
					<input type="text" name="userPass" id="userPass" value="${userPass}">
					<label for="email" data-icon="mail">邮件：</label> 
					<input type="email" name="email" id="email" placeholder="您的邮件地址..">
				</div>
			</form>
			<a href="#" id="confirmAttach" data-role="button" data-icon="check" data-theme="b">确认注册</a>
			<a href="#" id="backLogin" data-role="button" data-icon="back">返回登录</a>
		</div>
		<div data-role="footer" class="ui-btn" data-position="fixed"><!-- fixed -->
	  	 <p>&copy; NET.GODBIRDS 2017 </p>
		</div>
	</div>
</body>
</html>